dofile( "GEO\\gsgeo.lua" ) -- load GEO SDK
if not G then error( "GEO SDK Failed to load, cannot continue." ) end
do
	local quad = G:newEnt {
		angle = 0.0
	}
	
	G.core.with( quad.render, {
		
		beforePass = function( this, pass )
			if not this.visible then return false end
			
			gs.render_pushmatrix()
			gs.render_rotate( this.ent.angle, 0, 0, -1 )
			
			return true
		end;
		
		afterPass = function( this, pass )
			gs.render_popmatrix()
		end;
		
		onPass = function( this, pass )
			gs.render_glbegin_quads()
			gs.render_color( 0.5, 0.5, 0.5, 1.0 )	gs.render_vertex( 1, 1, -4 )
			gs.render_color( 0.5, 0, 0, 1.0 )		gs.render_vertex( -1, 1, -4 )
			gs.render_color( 0, 0.5, 0, 1.0 )		gs.render_vertex( -1, -1, -4 )
			gs.render_color( 0, 0, 0.5, 1.0 )		gs.render_vertex( 1, -1, -4 )
			gs.render_glend()
		end
	}):buildPipeline()
	
	G.core.with( G.state:newFrame(), {
		step = function( this )
			
			if gs.getKey(VK.ESCAPE) then return false
			
			elseif gs.getKey(VK.LEFT) then quad.angle = quad.angle - 180 * DELTA
			elseif gs.getKey(VK.RIGHT) then quad.angle = quad.angle + 180 * DELTA
				
			end
			
			return true
		end
	})
	
	G.core.with( G.render:newPass(), {
		
		beforeRender = function()
			gs.resetCamera()
			gs.render_resetmatrix()
			gs.render_lookat( 0, 0, 0,  0, 0, -1,  0, 1, 0 )
			gs.render_clearbuffer()
			
			return true
		end;
		
		afterRender = function()
			gs.render_flush()
		end
	})
	
end

if not gs.createWindow( "Godsource Engine", 640, 480, -1, -1 ) then error("Creating Window... Failed!\n" )
else print( "Creating Window... Success") end
G.LoadHooks()
gs.init_success = true
